package com.mm.mindmap.controller;

import com.mm.common.annotation.Log;
import com.mm.common.domain.po.Result;

import com.mm.mindmap.service.RecordServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/record")
@RequiredArgsConstructor
@Api(tags = "记录相关接口")
public class RecordController {

    private final RecordServiceImpl recordService;

    @Log(name = "获取所有收藏")
    @ApiOperation("获取所有收藏")
    @GetMapping("/getAllCollect")
    public Result getAllCollect() {
        return recordService.getAllCollect();
    }

    @Log(name = "点赞")
    @ApiOperation("点赞")
    @PostMapping("/like")
    public Result like(Long mid) {
        return recordService.like(mid);
    }

    @Log(name = "取消点赞")
    @ApiOperation("取消点赞")
    @PostMapping("/unlike")
    public Result unLike(Long mid) {
        return recordService.unLike(mid);
    }

    @Log(name = "收藏")
    @ApiOperation("收藏")
    @PostMapping("/collect")
    public Result collect(Long mid) {
        return recordService.collect(mid);
    }

    @Log(name = "取消收藏")
    @ApiOperation("取消收藏")
    @PostMapping("/uncollect")
    public Result unCollect(Long mid) {
        return recordService.unCollect(mid);
    }
}
